//
//  Created by  fred on 2017/1/12.
//  Copyright © 2016年 Alibaba. All rights reserved.
//

package com.atguigu.msmservice.utils;
import com.alibaba.cloudapi.sdk.client.ApacheHttpClient;
import com.alibaba.cloudapi.sdk.enums.Scheme;
import com.alibaba.cloudapi.sdk.enums.HttpMethod;
import com.alibaba.cloudapi.sdk.model.ApiRequest;
import com.alibaba.cloudapi.sdk.model.ApiResponse;
import com.alibaba.cloudapi.sdk.model.ApiCallback;
import com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams;
import com.alibaba.cloudapi.sdk.enums.ParamPosition;
import com.alibaba.cloudapi.sdk.enums.WebSocketApiType;
import com.alibaba.fastjson.JSONObject;


public class HttpApiClient鼎信短信平台 extends ApacheHttpClient{
    public final static String HOST = "dingxin.market.alicloudapi.com";
    static HttpApiClient鼎信短信平台 instance = new HttpApiClient鼎信短信平台();
    public static HttpApiClient鼎信短信平台 getInstance(){return instance;}

    public void init(HttpClientBuilderParams httpClientBuilderParams){
        httpClientBuilderParams.setScheme(Scheme.HTTP);
        httpClientBuilderParams.setHost(HOST);
        super.init(httpClientBuilderParams);
    }


    /**
     *
     * @param mobile 手机号
     * @param param 数据，code：验证码
     * @param tpl_id 模板编号：TP1711063
     * @param callback
     */
    public void 鼎信科技_短信验证码_短信通知API(String mobile , String param , String tpl_id , ApiCallback callback) {
        String path = "/dx/sendSms";
        ApiRequest request = new ApiRequest(HttpMethod.POST_FORM , path);
        request.addParam("mobile" , mobile , ParamPosition.QUERY , true);
        request.addParam("param" , param , ParamPosition.QUERY , false);
        request.addParam("tpl_id" , tpl_id , ParamPosition.QUERY , true);



        sendAsyncRequest(request , callback);
    }

    /**
     *
     * @param mobile 手机号
     * @param param 数据，code：验证码
     * @param tpl_id 模板编号：TP1711063
     * @return
     */
    public ApiResponse 鼎信科技_短信验证码_短信通知APISyncMode(String mobile , String param , String tpl_id) {
        String path = "/dx/sendSms";
        ApiRequest request = new ApiRequest(HttpMethod.POST_FORM , path);
        request.addParam("mobile" , mobile , ParamPosition.QUERY , true);
        request.addParam("param" , param , ParamPosition.QUERY , false);
        request.addParam("tpl_id" , tpl_id , ParamPosition.QUERY , true);



        return sendSyncRequest(request);
    }

}
